﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Uber.HabboHotel.Users.Subscriptions
{
    class Subscription
    {
        public string Type;

        public int Months;

        public DateTime Activated;

        public int ItemsSelected;

        public int MonthsLeft
        {
            get
            {
                return (((Months * 31) - (int)(DateTime.Now - Activated).TotalDays) / 31);
            }
        }

        public int DaysLeft
        {
            get
            {
                return (((Months * 31) - (int)(DateTime.Now - Activated).TotalDays) - (MonthsLeft * 31));
            }
        }

        public int DaysDone
        {
            get
            {
                int Diff = (int)(DateTime.Now - Activated).TotalDays;

                if (Diff > (Months * 31))
                {
                    Diff = (Months * 31);
                }

                return Diff;
            }
        }

        public int DaysToWait
        {
            get
            {
                return 7; // todo
            }
        }

        public int ItemsToSelect
        {
            get
            {
                int Count = ((int)(DaysDone / 7) - ItemsSelected);

                if (Count < 0)
                {
                    Count = 0;
                }

                return Count;
            }
        }
        
        public Subscription(string mType, string mActivated, int mMonths, int mItemsSelected)
        {
            this.Type = mType;
            this.Months = mMonths;
            this.ItemsSelected = mItemsSelected;

            this.Activated = DateTime.Parse(mActivated);
        }

        public Boolean IsValid()
        {
            TimeSpan Diff = (DateTime.Now - Activated);

            if ((Diff.TotalDays / 31) == Months)
            {
                return false;
            }

            return true;
        }
    }
}
